package constant.milk.cashbook.apt;

import constant.milk.cashbook.database.DbAdapter;
import constant.milk.cashbook.database.DbCreateQuery;
import constant.milk.cashbook.database.TableName;
import android.content.Context;

public class AptSetting
{
	private Context context;
	private DbAdapter db;
	private DbCreateQuery createQuery;
	
	public AptSetting(Context context, DbAdapter db)
	{
		this.context = context;
		this.db = db;
		createQuery = new DbCreateQuery(db.getDb(context));
	}
	
	public void setting() throws Exception
	{
		createQuery.createAptDataTable();
		createQuery.createMyHouseTable();
		db.delete(context, TableName.APT_DATA, null, null);
		
		BusanSetting busan = new BusanSetting(context, db);
		busan.Setting();
		
		ChungcheongbukdoSetting chungcheongbukdo = new ChungcheongbukdoSetting(context, db);
		chungcheongbukdo.Setting();
		
		ChungcheongnamdoSetting chungcheonnamdo = new ChungcheongnamdoSetting(context, db);
		chungcheonnamdo.Setting();
		
		DaeGuSetting daegu = new DaeGuSetting(context, db);
		daegu.Setting();
		
		DaejeonSetting daejeon = new DaejeonSetting(context, db);
		daejeon.Setting();
		
		GangwondoSetting gangwon = new GangwondoSetting(context, db);
		gangwon.Setting();
		
		GwangjuSetting gwangju = new GwangjuSetting(context, db);
		gwangju.Setting();
		
		GyeonggidoSetting gyeonggi = new GyeonggidoSetting(context, db);
		gyeonggi.Setting();
		
		GyeongsangbukdoSetting gyeongsangbukdo = new GyeongsangbukdoSetting(context, db);
		gyeongsangbukdo.Setting();
		
		GyeongsangnamdoSetting gyeongsangnamdo = new GyeongsangnamdoSetting(context, db);
		gyeongsangnamdo.Setting();
		
		IncheonSetting incheon = new IncheonSetting(context, db);
		incheon.Setting();
		
		JejudoSetting jeju = new JejudoSetting(context, db);
		jeju.Setting();
		
		JeollabukdoSetting jeollabukdo = new JeollabukdoSetting(context, db);
		jeollabukdo.Setting();
		
		JeollanamdoSetting jeollanamdo = new JeollanamdoSetting(context, db);
		jeollanamdo.Setting();
		
		SeojongSetting seojong = new SeojongSetting(context, db);
		seojong.Setting();
		
		SeoulSetting seoul = new SeoulSetting(context, db);
		seoul.Setting();
		
		UlsanSetting ulsan = new UlsanSetting(context, db);
		ulsan.Setting();
	}
	
	public void setBeginTansaction() throws Exception
	{
		db.beginTansaction(context);
	}
	
	public void setSuccessful() throws Exception
	{
		db.setTransactionSuccessful();
	}
	
	public void setEndTansaction() throws Exception
	{
		db.endTransaction(context);
	}
}
